import 'package:flutter_module/beans/base_bean.dart';
import 'package:flutter_module/util/string_utils.dart';

class ElementBean extends BaseBean {
  ///id 唯一标识
  String uuid;

  ///数据图层关联ID
  final String layerId;

  ///显示样式
  String displayStyle;

  ///显示用的主名称
  String displayText;

  ///几何
  String geometry;

  ///状态  0 无； 1 删除；2 更新；3 新增；
  int tLifecycle;

  ///采集端作业状态   0 未作业；1 已作业； 2 已提交；
  int tStatus;

  ///记录android端最后一次操作的时间
  String tOperateDate;

  Map<String, dynamic> values;

  ElementBean({
    this.uuid = "",
    required this.layerId,
    required this.geometry,
    required this.values,
    this.displayStyle = "",
    this.displayText = "",
    this.tLifecycle = 3,
    this.tStatus = 1,
    this.tOperateDate = "",
  }) {
    if (uuid == "") {
      uuid = StringUtil.createUUID();
    }
  }

  @override
  Map<String, dynamic> toMap() {
    return {
      "uuid": uuid,
      "layerId": layerId,
      "displayStyle": displayStyle,
      "displayText": displayText,
      "geometry": geometry,
      "tLifecycle": tLifecycle,
      "tStatus": tStatus,
      "tOperateDate": tOperateDate,
      "values": values,
    };
  }

  factory ElementBean.fromMap(Map map) {
    return ElementBean(
        layerId: map["layerId"],
        uuid: map["uuid"],
        geometry: map["geometry"],
        displayText: map["displayText"],
        tOperateDate: map["tOperateDate"],
        tLifecycle: map["tLifecycle"],
        tStatus: map["tStatus"],
        values: Map.castFrom(map["values"]));
  }
}
